<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="visualisation.css">
<TITLE>
Program annotation
</TITLE>
</HEAD>
<BODY >
<A HREF="visualisation001.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="visualisation003.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H1 CLASS="chapter"><A NAME="htoc2">Chapter&nbsp;2</A>&nbsp;&nbsp;Program annotation</H1><UL>
<LI><A HREF="visualisation002.html#toc1">Viewables</A>
</UL>

When visualising CLP program behaviour, not all the variables of the
program are of interest. ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> supports the concept of a set of
<A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default0"></A> variables whose state over the course of a program run are
of interest to the user. The library
<A HREF="../bips/lib/viewable/index.html"><B>lib(viewable)</B></A><A NAME="@default1"></A> contains the
annotation predicates that allow a programmer to define (and expand)
these <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default2"></A> sets.<BR>
<BR>
<A NAME="toc1"></A>
<H2 CLASS="section"><A NAME="htoc3">2.1</A>&nbsp;&nbsp;Viewables</H2>
<A NAME="sec:viewables"></A>
By collecting together related program
variables into a logical, multidimensional array-like structure called
a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default3"></A>, the user can view the changing state of these variables
in a number of ways using the provided visualisation clients (these
will be covered in depth later (section <A HREF="visualisation003.html#sec:visu-clients">3</A>)).<BR>
<BR>
As an example of how to annotate an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> program, consider the
following classic cryptographic example, <TT>SEND+MORE=MONEY</TT><BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    Carries = [C1,C2,C3,C4],
    Carries :: [0..1],
    alldifferent(Digits),
    S #<CODE>\</CODE>= 0,
    M #<CODE>\</CODE>= 0,
    C1         #= M,
    C2 + S + M #= O + 10*C1,
    C3 + E + O #= N + 10*C2,
    C4 + N + R #= E + 10*C3,
         D + E #= Y + 10*C4,
    labeling(Carries),
    labeling(Digits).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
It is hopefully clear from the code that this formulation of the
classic puzzle uses four variables <TT>[C1,C2,C3,C4]</TT> to indicate
the <EM>carry</EM> digits. If we suppose that the user is only
interested in the behaviour of the program with respect to the primary
problem variables, which in this case corresponds to the variables
<TT>[S,E,N,D,M,O,R,Y]</TT>, then we can annotate the program code by
declaring a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default4"></A> which contains these variables.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    viewable_create(digits, Digits),
    ...
    ...
    labeling(Carries),
    labeling(Digits).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
As can be seen, <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default5"></A>s are declared using the
<A HREF="../bips/lib/viewable/viewable_create-2.html"><B>viewable_create/2</B></A><A NAME="@default6"></A> predicate, the first parameter of which is an
atom which will be used to uniquely identify the <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default7"></A> later,
and the second argument is a (possibly nested) list of variables.<BR>
<BR>
Declaring <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default8"></A>s has little performance overhead when running
code normally (that is to say, without any visualisation clients), and
so it is safe to leave the visualisation annotations in the code even
when not visualising.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc4">2.1.1</A>&nbsp;&nbsp;2D and beyond</H3>
In the previous example, the created <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default9"></A> was a simple one
dimensional structure, it is possible however to create
multi-dimensional structures if the problem variables are so related.
For example one could choose to group the variables in a way that
mirrors the problem structure, for example a 2D array representing the
equation<BR>
<BR>
<DIV CLASS="center">
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=center NOWRAP>&nbsp;</TD>
<TD ALIGN=center NOWRAP>S</TD>
<TD ALIGN=center NOWRAP>E</TD>
<TD ALIGN=center NOWRAP>N</TD>
<TD ALIGN=center NOWRAP>D</TD>
</TR>
<TR><TD ALIGN=center NOWRAP>+</TD>
<TD ALIGN=center NOWRAP>M</TD>
<TD ALIGN=center NOWRAP>O</TD>
<TD ALIGN=center NOWRAP>R</TD>
<TD ALIGN=center NOWRAP>E</TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=5><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD ALIGN=center NOWRAP>M</TD>
<TD ALIGN=center NOWRAP>O</TD>
<TD ALIGN=center NOWRAP>N</TD>
<TD ALIGN=center NOWRAP>E</TD>
<TD ALIGN=center NOWRAP>Y</TD>
</TR></TABLE>
</DIV><BR>
<BR>
would be the array
<DIV CLASS="center"><TABLE CELLSPACING=0 CELLPADDING=0>
<TR VALIGN=middle><TD NOWRAP >
</TD>
<TD NOWRAP>&#9115;<BR>
&#9116;<BR>
&#9116;<BR>
&#9117;</TD>
<TD NOWRAP><TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=center NOWRAP>0</TD>
<TD ALIGN=center NOWRAP><I>S</I></TD>
<TD ALIGN=center NOWRAP><I>E</I></TD>
<TD ALIGN=center NOWRAP><I>N</I></TD>
<TD ALIGN=center NOWRAP><I>D</I></TD>
</TR>
<TR><TD ALIGN=center NOWRAP>0</TD>
<TD ALIGN=center NOWRAP><I>M</I></TD>
<TD ALIGN=center NOWRAP><I>O</I></TD>
<TD ALIGN=center NOWRAP><I>R</I></TD>
<TD ALIGN=center NOWRAP><I>E</I></TD>
</TR>
<TR><TD ALIGN=center NOWRAP><I>M</I></TD>
<TD ALIGN=center NOWRAP><I>O</I></TD>
<TD ALIGN=center NOWRAP><I>N</I></TD>
<TD ALIGN=center NOWRAP><I>E</I></TD>
<TD ALIGN=center NOWRAP><I>Y</I></TD>
</TR></TABLE></TD>
<TD NOWRAP>&#9118;<BR>
&#9119;<BR>
&#9119;<BR>
&#9120;</TD>
</TR></TABLE></DIV><BR>
<BR>
and would be declared in the program as nested lists
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
viewable_create(equation,[[0, S, E, N, D],[0, M, O, R, E],[M, O, N, E, Y]]
</PRE></BLOCKQUOTE>
or it could be declared in the program using ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> array syntax
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
viewable_create(equation,[]([](0, S, E, N, D),
                            [](0, M, O, R, E),
                            [](M, O, N, E, Y)))
</PRE></BLOCKQUOTE>
Three points should be noted here,
<OL CLASS="enumerate" type=1><LI CLASS="li-enumerate">
<A HREF="../bips/lib/viewable/viewable_create-2.html"><B>viewable_create/2</B></A><A NAME="@default10"></A> accepts both nested lists and arrays.
<LI CLASS="li-enumerate">Variables may occur more than once in <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default11"></A>.
<LI CLASS="li-enumerate">Constants may occur in <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default12"></A>s.
</OL>

<H3 CLASS="subsection"><A NAME="htoc5">2.1.2</A>&nbsp;&nbsp;Growth</H3>
So far we have introduced only static (or <EM>fixed</EM> dimension)
<A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default13"></A>s, but it is conceivable that during the course of program
runs new variables may be introduced which the user has an interest in
looking at. In order to accommodate this, <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default14"></A>s may be
declared as having <EM>flexible</EM> dimensions.<BR>
<BR>
To declare a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default15"></A> with flexible dimensions, the three argument
form of the <A HREF="../bips/lib/viewable/viewable_create-3.html"><B>viewable_create/3</B></A><A NAME="@default16"></A> predicate is used. The third
argument specifies the type of the <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default17"></A> and at present the type
must be of the form <TT>array(FixityList, ElementType)</TT> where
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B><TT>FixityList</TT></B><DD CLASS="dd-description"> is a list with an atom <TT>fixed</TT> or
<TT>flexible</TT> specifying the fixity for each dimension. The fixity
denotes whether the dimension's size is fixed or may vary during the
time when the viewable is existent.
<DT CLASS="dt-description"><B><TT>ElementType</TT></B><DD CLASS="dd-description"> is a term which specifies the type of the
constituent viewable elements. Currently there are two supported
element types:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
 <B><TT>any</TT></B><DD CLASS="dd-description"> which includes any ECLiPSe term.
 <DT CLASS="dt-description"><B><TT>numeric_bounds</TT></B><DD CLASS="dd-description"> which includes any ground number,
 integer <A HREF="../bips/lib/fd/index.html"><B>fd</B></A><A NAME="@default18"></A> variables,
 <A HREF="../bips/lib/ic/index.html"><B>ic</B></A><A NAME="@default19"></A> variables and
 <A HREF="../bips/lib/range/index.html"><B>range</B></A><A NAME="@default20"></A> variables (including
 <A HREF="../bips/lib/eplex/index.html"><B>eplex</B></A><A NAME="@default21"></A> and
 <A HREF="../bips/lib/ria/index.html"><B>ria</B></A><A NAME="@default22"></A> variables).
 </DL></DL>
Let us expand our example by assuming that, during the program run our
user is only interested in the <EM>digit</EM> variables but once
labelling has finished they wish to also see the <EM>carry</EM>
variables. Clearly the user is free to simply print out the
<EM>carry</EM> variables after completing the labelling, but within the
visualisation framework they may also expand the viewable by adding
the <EM>carry</EM> digits to it. The code to do this is<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    viewable_create(equation,
                    []([](0, S, E, N, D),
                       [](0, M, O, R, E),
                       [](M, O, N, E, Y)),
                    array([flexible,fixed], any)),
    ...
    ...
    labeling(Carries),
    labeling(Digits),
    viewable_expand(equation, 1, [C1, C2, C3, C4, 0]).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
Once declared as flexible, dimensions may be expanded by the
<A HREF="../bips/lib/viewable/viewable_expand-3.html"><B>viewable_expand/3</B></A><A NAME="@default23"></A> predicate. The predicate specifies which
dimension to expand and which values should be added. Had the
<A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default24"></A> been 3 dimensional, then the values to be added would need
to be 2 dimensional. In general for an N dimensional <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default25"></A>,
when expanding a flexible dimension, the values to be added must be
N-1 dimensional arrays or nested lists.<BR>
<BR>
As with <A HREF="../bips/lib/viewable/viewable_create-2.html"><B>viewable_create/2</B></A><A NAME="@default26"></A> and <A HREF="../bips/lib/viewable/viewable_create-3.html"><B>viewable_create/3</B></A><A NAME="@default27"></A>,
<A HREF="../bips/lib/viewable/viewable_expand-3.html"><B>viewable_expand/3</B></A><A NAME="@default28"></A> silently succeeds with little overhead at
runtime, so it too may be left in code even when not visualising.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc6">2.1.3</A>&nbsp;&nbsp;Types</H3>
As mentioned briefly in the previous section, <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default29"></A>s have a type
definition which determines what sort of values may be stored in them.
This type information allows visualisation clients to render the
values in a fitting manner.<BR>
<BR>
Explicitly stating that the variables in a viewable are
<TT>numeric_bounds</TT> where known will increase the number
of ways in which the
<A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default30"></A> elements may be viewed.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc7">2.1.4</A>&nbsp;&nbsp;Named dimensions</H3>
Each position in a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default31"></A>'s dimension has an associated name. By
default, these names are simply the increasing natural numbers
starting from &#8220;1&#8221;. So, for example, in the previous code samples
the variable <TT>R</TT> would be at location <TT>["2","4"]</TT>.<BR>
<BR>
By using the most expressive form, the <A HREF="../bips/lib/viewable/viewable_create-4.html"><B>viewable_create/4</B></A><A NAME="@default32"></A> predicate
allows the user to assign their own symbolic names to dimension
locations.<BR>
<BR>
In our ongoing example, we could name the first dimension positions
<TT>["send", "more", "money"]</TT> and the second dimension positions
<TT>["ten thousands", "thousands", "hundreds", "tens", "units"]</TT>.<BR>
<BR>
A version of <A HREF="../bips/lib/viewable/viewable_expand-4.html"><B>viewable_expand/4</B></A><A NAME="@default33"></A> exists also which allows the user to
assign a name to the new position of an expanded dimension.<BR>
<BR>
Our completed example now looks like this<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
:-lib(viewable).

sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    viewable_create(equation,
                    []([](0, S, E, N, D),
                       [](0, M, O, R, E),
                       [](M, O, N, E, Y)),
                    array([flexible,fixed], numeric_bounds),
                    [["send", "more", "money"],
                     ["ten thousands", "thousands",
                      "hundreds", "tens", "units"]]),
    Carries = [C1,C2,C3,C4],
    Carries :: [0..1],
    alldifferent(Digits),
    S #<CODE>\</CODE>= 0,
    M #<CODE>\</CODE>= 0,
    C1         #= M,
    C2 + S + M #= O + 10*C1,
    C3 + E + O #= N + 10*C2,
    C4 + N + R #= E + 10*C3,
         D + E #= Y + 10*C4,
    labeling(Carries),
    labeling(Digits),
    viewable_expand(equation, 1, [C1, C2, C3, C4, 0], "carries").
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>

<H3 CLASS="subsection"><A NAME="htoc8">2.1.5</A>&nbsp;&nbsp;Structured data</H3>
In an effort to increase the ease with which program behaviour can be
viewed and to provide tighter integration between ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> modules,
data held in graph structures can also be annotated.<BR>
<BR>
The following code demonstrates how a simple graph structure from the
<A HREF="../bips/lib/graph_algorithms/index.html"><B>lib(graph_algorithms)</B></A><A NAME="@default34"></A>
library can be used to define a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default35"></A>.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
:-lib(graph_algorithms).
:-lib(viewable).
:-lib(ic).

test:-
    make_graph(7,
               [e(1,2,F12), e(2,3,F23), e(2,4,F24), e(3,5,F35),
                e(4,5,F45), e(4,6,F46), e(5,6,F56), e(6,3,F63),
                e(6,7,F67)],
               Graph),
    Flows = [F23,F24,F35,F45,F46,F56,F63],
    Flows :: 0..5,
    (for(Node, 2, 6), param(Graph) do
        graph_get_incoming_edges(Graph, Node, InEdges),
        graph_get_adjacent_edges(Graph, Node, OutEdges),
        (foreach(e(_From, _To, Flow), InEdges),
         foreach(Flow, InFlow) do true),
        (foreach(e(_From, _To, Flow), OutEdges),
         foreach(Flow, OutFlow) do true),
        sum(InFlow) #= sum(OutFlow)
    ),
    F12 #= 9,
    viewable_create(flow_viewable, Graph, graph(fixed),
                    [node_property([0-&gt;[name(nodes), label]]),
                     edge_property([0-&gt;[name(edges), label]])
                    ]),
    labeling(Flows).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
This simple network flow problem uses the graph structure to hold the
problem variables and also to define the network topology. Note the
single <A HREF="../bips/lib/viewable/viewable_create-4.html"><B>viewable_create/4</B></A><A NAME="@default36"></A> statement immediately before the
labeling step.<BR>
<BR>
As with the regular list/array based viewable create calls, the first
argument specifies the viewable name and the structure containing the
variables of interest (in this case the graph) comes second. The
third argument defines the type as being a graph whose structure is
fixed (as all graph_algorithms graphs are). Currently only fixed
graphs are supported. The final (optional) argument defines a mapping
between the node/edge structures within the graph and properties
useful for visualisation. The table below outlines the currently
supported properties.<BR>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>
<TR><TD VALIGN=top ALIGN=left NOWRAP>markup</TD>
<TD VALIGN=top ALIGN=left>meaning</TD>
<TD VALIGN=top ALIGN=center NOWRAP>applicability</TD>
<TD VALIGN=top ALIGN=center NOWRAP>required</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>name(String)</TD>
<TD VALIGN=top ALIGN=left>A unique name to refer to this property</TD>
<TD VALIGN=top ALIGN=center NOWRAP>both</TD>
<TD VALIGN=top ALIGN=center NOWRAP>yes</TD>
</TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>label</TD>
<TD VALIGN=top ALIGN=left>This property should be used as the node/edge text label</TD>
<TD VALIGN=top ALIGN=center NOWRAP>both</TD>
<TD VALIGN=top ALIGN=center NOWRAP>yes</TD>
</TR></TABLE>
For more control over the display of graphs structures, consider using
the <A HREF="../bips/lib/graphviz/index.html"><B>lib(graphviz)</B></A><A NAME="@default37"></A> library.<BR>
<BR>

<H3 CLASS="subsection"><A NAME="htoc9">2.1.6</A>&nbsp;&nbsp;Solver variables</H3>
The program annotations shown so far will work with most solvers in
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> but not all. Generally speaking if the solver operates by
monotonically reducing the domain of its variables then no further
annotations are required. There are solvers however which do not
manipulate variables in this way. For instance the
<A HREF="../bips/lib/eplex/index.html"><B>lib(eplex)</B></A><A NAME="@default38"></A> library uses
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> program variables as handles to the values calculated by an
external solver. When solutions are found by the external solver, the
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> variables are not (always) instantiated but rather must be
queried to obtain their values.<BR>
<BR>
In order to facilitate the visualisation of such variables, the same
<A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default39"></A>creation annotations can be used, but the name of the solver
must be given explicitly. As an example consider the following
<A HREF="../bips/lib/eplex/index.html"><B>lib(eplex)</B></A><A NAME="@default40"></A> model of a simple
transportation problem involving 3 factories <TT>1,2,3</TT> and 4
clients <TT>A,B,C,D</TT> taken from the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> examples web page.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
%&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
% Example for basic use of ECLiPSe/CPLEX interface
%
% Distribution problem taken from EuroDecision chapter in D4.1
%&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-

:- lib(eplex_xpress).
:- eplex_instance(foo).

%&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
% Explicit version (clients A-D, plants 1-3)
%&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-

main(Cost, Vars) :-
        Vars = [A1, B1, C1, D1, A2, B2, C2, D2, A3, B3, C3, D3],
        foo:(Vars :: 0.0..10000.0),              % variables

        foo:(A1 + A2 + A3 $= 200),               % demand constraints
        foo:(B1 + B2 + B3 $= 400),
        foo:(C1 + C2 + C3 $= 300),
        foo:(D1 + D2 + D3 $= 100),

        foo:(A1 + B1 + C1 + D1 $=&lt; 500),         % capacity constraints
        foo:(A2 + B2 + C2 + D2 $=&lt; 300),
        foo:(A3 + B3 + C3 + D3 $=&lt; 400),

        foo:eplex_solver_setup(
                       min(                      % solve
                           10*A1 + 7*A2 + 11*A3 +
                           8*B1 + 5*B2 + 10*B3 +
                           5*C1 + 5*C2 +  8*C3 +
                           9*D1 + 3*D2 +  7*D3)),

        foo:eplex_solve(Cost).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
Adding the following line immediately before the call to
<TT>eplex_solve/1</TT> indicates that the solution values computed by
the eplex instance <TT>foo</TT> are of interest. Note the
<EM>element type</EM> field of the third argument says that the values
of interest may be changed by the solver <TT>foo</TT>. Further note
that you will need to load the <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default41"></A>library inorder to access
these annotations.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
viewable_create(vars, Vars
                array([fixed], changeable(foo, any))),
</PRE></BLOCKQUOTE></TD>
</TR></TABLE> <BR>
This <EM>changeable</EM> element type can appear in any form of the
annotations, so as another example, the following annotation gives
more structure to the variables.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
viewable_create(vars, []([](A1, A2, A3),
                         [](B1, B2, B3),
                         [](C1, C2, C3),
                         [](D1, D2, D3)),
                array([fixed,fixed], changeable(foo, any))),
</PRE></BLOCKQUOTE></TD>
</TR></TABLE> <BR>
As a final example, adding these two lines will make the structure of
the problem even more explicit.<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
make_graph_symbolic([]('A','B','C','D',1,2,3),
                    [edge(1,'A',A1),edge(2,'A',A2),edge(3,'A',A3),
                     edge(1,'B',B1),edge(2,'B',B2),edge(3,'B',B3),
                     edge(1,'C',C1),edge(2,'C',C2),edge(3,'C',C3),
                     edge(1,'D',D1),edge(2,'D',D2),edge(3,'D',D3)],G),
viewable_create(network, G, graph(fixed,changeable(foo,graph_data))),
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>

	<BLOCKQUOTE CLASS="figure"><DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV>
	<DIV CLASS="center">
	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#DB9370">
	
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>viewable_create</B><A HREF="../bips/lib/viewable/viewable_create-2.html"><B>/2</B></A><A HREF="../bips/lib/viewable/viewable_create-3.html"><B>/3</B></A><A HREF="../bips/lib/viewable/viewable_create-4.html"><B>/4</B></A><DD CLASS="dd-description">
 used to group problem variables for visualisation purposes. Groupings
 referred to as <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default42"></A>s.
<DT CLASS="dt-description"><B>viewable_expand</B><A HREF="../bips/lib/viewable/viewable_expand-3.html"><B>/3</B></A><A HREF="../bips/lib/viewable/viewable_expand-4.html"><B>/4</B></A><DD CLASS="dd-description"> <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default43"></A>s can be of a fixed size, or can expand and shrink.
<DT CLASS="dt-description"><B>types</B><DD CLASS="dd-description"> elements of a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default44"></A> may be defined as being numeric values or may be any ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>term. The type of a <A HREF="../bips/lib/viewable/index.html"><B>viewable</B></A><A NAME="@default45"></A> will determine how it can be visualised.
<DT CLASS="dt-description"><B>structure</B><DD CLASS="dd-description"> interesting variables contained within graph structures can be directly annotated using the <TT>graph(static)</TT> viewable type.
</DL>

	</TD>
</TR></TABLE>
	</DIV>
	<BR>
<BR>
<DIV CLASS="center">Figure 2.1: Overview of program annotation</DIV><BR>
<BR>

	<DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV></BLOCKQUOTE>


<HR>
<A HREF="visualisation001.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="visualisation003.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
